#import "HomeViewController.h"
#import "IntroductionViewController.h"
#import "GameViewController.h"

@interface HomeViewController ()

@end

@implementation HomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIImageView *homeImage = [UIImageView new];
    homeImage.frame = SCREEN_BOUND;
    homeImage.image = [UIImage imageNamed:@"myrank_bg.jpg"];
    [self.view addSubview:homeImage];
    homeImage.userInteractionEnabled = YES;
    
    UIImageView *logoImage = [UIImageView new];
    int logoX = (SCREEN_WIDTH)/4 ;
    int logoY = (SCREEN_HEIGHT*1)/3 ;
    int logoW = (SCREEN_WIDTH)/2 ;
    logoImage.frame = CGRectMake(logoX, logoY, logoW, logoW/3);
    logoImage.image = [UIImage imageNamed:@"logo"];
    [homeImage addSubview:logoImage];
    
    UIButton *btn1 = [UIButton new];
    btn1.frame = CGRectMake(logoX*4/3, logoY+(logoW/3)+30, logoW*2/3, 40);
    [btn1 setTitle:@"开始游戏" forState:0];
    btn1.backgroundColor = GRAY_COLOR;
    [btn1 addTarget:self action:@selector(startGame) forControlEvents:UIControlEventTouchUpInside];
    [homeImage addSubview:btn1];
    
    UIButton *btn2 = [UIButton new];
    btn2.frame = CGRectMake(logoX*4/3, logoY+(logoW/3)+85, logoW*2/3, 40);
    [btn2 setTitle:@"操作说明" forState:0];
    btn2.backgroundColor = GRAY_COLOR;
    [btn2 addTarget:self action:@selector(introduction) forControlEvents:UIControlEventTouchUpInside];
    [homeImage addSubview:btn2];
    
}

-(void)startGame{
    //跳转到游戏主界面
    GameViewController *gameView = [GameViewController new];
    gameView.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentViewController:gameView animated:NO completion:nil];
}

-(void)introduction{
    //跳转到说明界面
    IntroductionViewController *introView = [IntroductionViewController new];
    introView.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentViewController:introView animated:NO completion:nil];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
